package cn.com.huzo.service.tech.impl;

import cn.com.huzo.model.entities.tech.ProductBomLinesPictureEntity;
import huzofw.common.util.file.DeleteDirectoryAndFile;
import huzofw.service.impl.GenericManagerImpl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.com.huzo.repository.tech.ProductBomLinesPictureRepository;
import cn.com.huzo.service.tech.ProductBomLinesPictureManager;

/**
 * EBOM图片管理服务对象类实现。
 *
 * @author 吴旭
 */
@Service("ProductBomLinesPictureManager")
public class ProductBomLinesPictureManagerImpl extends GenericManagerImpl<ProductBomLinesPictureEntity, String>
        implements ProductBomLinesPictureManager {

    @Resource(name = "ProductBomLinesPictureRepository")
    private ProductBomLinesPictureRepository _dao_lines_picture;

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public List<ProductBomLinesPictureEntity> fetchAll(Long headerId) throws Exception {
        return _dao_lines_picture.fetchAll(headerId);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public String insert(ProductBomLinesPictureEntity instance) throws Exception {
        return _dao_lines_picture.insert(instance);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public Integer delete(ProductBomLinesPictureEntity instance) throws Exception {
        DeleteDirectoryAndFile.deleteFile(instance.getImageFileDir() + "/" + instance.getImageFileName());
        return _dao_lines_picture.delete(instance.getLinesId());
    }
}
